import Vue from 'vue'
import Vuex from 'vuex'

import { constants } from '../common/js/constants.js'
import mutations from './mutations.js'
import actions from './actions.js'

Vue.use(Vuex)

// localStorage.getItem('token'),这样子刷新页面就无需重新登录
const state = {
  isLoggedIn: false,
  token: window.localStorage.getItem(constants.STORAGE_TOKEN_KEY),
  userInfo: {
    email: '',
    username: '未登录'
  }
}

const getters = {

}

const store = new Vuex.Store({
  state,
  getters,
  mutations,
  actions
})

export default store
